﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyRabbit.Application.Command.ImmuneCommand;
using MyRabbit.Application.Dtos;
using MyRabbit.Application.ErrorCode;

namespace MyRabbit.Web.Api.Controllers
{
    /// <summary>
    /// 免疫控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ImmuneController : ControllerBase
    {
        private readonly IMediator mediator;
        public ImmuneController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 添加免疫
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddImmune(AddImmuneCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 显示免疫
        /// </summary>
        /// <param name="breedId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<ImmuneDTO>>> QueryImmune(int breedId)
        {
            ImmuneQueryCommand command = new ImmuneQueryCommand();
            command.BreedId = breedId;
            return await mediator.Send(command);
        }




    }
}
